//当我在终端输入node 2.jd rock(石头)， 电脑能自动随机出一个，并输出我们的对战结果

//往进程中输入指令 rock(石头)
// console.log(process.argv)

var playerAction = process.argv[process.argv.length - 1]
// console.log(playerAction);//rock

//电脑随机生成 3 个
var random = Math.random() * 3;//生成 （0，3）之间的随机数
if(random <1 ){
    var computerAction = 'rock'
}
else if(random >2 ){
    var computerAction = 'scissor'
}else{
    var computerAction = 'paper'
}
console.log(computerAction)
//比较
if(computerAction ===playerAction)
{
    console.log('平局');
}else if(computerAction ==='rock'&&playerAction ==='paper'||
(computerAction ==='scissor'&&playerAction ==='rock') ||(computerAction ==='paper'&&playerAction ==='scissor')){
    console.log('你赢了');
}else{
    console.log('你输了');
}